// 冒泡、选择、插入、希尔、归并、快速、堆、计数、桶、基数排序
// https://www.runoob.com/w3cnote/ten-sorting-algorithm.html
// 原地冒泡
function bubbleSort(arr: number[]) {
  const L = arr.length
  let [front, back] = [0, 0]
  for (let i = 0; i < L; i++) {
    for (let j = 0; j < L - i; j++) {
      ;[front, back] = [arr[j] as number, arr[j + 1] as number]
      if (front > back) {
        ;[arr[j], arr[j + 1]] = [back, front]
      }
    }
  }
}

const test1 = [1, 5, 4, 3, 2, 6]
console.log(test1)
bubbleSort(test1)
console.log(test1)
